home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / CHGATTR.C < prev    next >
Text File  |  1990-04-27  |  3KB  |  77 lines

  1. /***********************************************************/
  2. /* File Id.                  ChgAttr.C                     */
  3. /* Author.                   Stan Milam.                   */
  4. /* Date Written.             03/06/89.                     */
  5. /*                                                         */
  6. /*            (c) Copyright 1989-90 by Stan Milam          */
  7. /*                                                         */
  8. /* Comments: This function will chage the color attributes */
  9. /* starting at row & col and continue for the count of cols*/
  10. /***********************************************************/
  11.  
  12. #include <dos.h>
  13. #include "pcw.i"
  14. #include "pcwproto.h"
  15.  
  16. int chg_attr(int row, int col, int fclr, int bclr, int count) {
  17.  
  18.    unsigned scrnseg, offset;
  19.    int far  *scrnptr;
  20.    int page, attr, pagesize;
  21.    int mx_rows, mx_cols;
  22.  
  23.    if (!chk_video_state(&mx_rows, &mx_cols)) return(0);
  24.    if (((col - 1) + count) > mx_cols)
  25.       count = count - (((col - 1) + count) - mx_cols);
  26.  
  27.    pagesize = getpagesize();
  28.    scrnseg  = getscrnseg();
  29.    page     = getpage();
  30.    attr     = MK_ATTR(fclr,bclr);
  31.    offset   = MK_SCRNOFF(row,col);
  32.    scrnptr  = (int far *) MK_FP(scrnseg,offset);
  33.    Tchg_Attr(scrnptr, count, attr);
  34.    return(1);
  35. }
  36.  
  37. /**********************************************************/
  38. /*                        W_Chg_Attr                      */
  39. /*                                                        */
  40. /* Change the attribute at row & col inside of a window.  */
  41. /* The change is confined inside of window boundries.     */
  42. /**********************************************************/
  43.  
  44. int w_chg_attr(wnd, row, col, foreground, background, count)
  45. WNDPTR *wnd;
  46. int    row, col, foreground, background, count; {
  47.  
  48.    int mxr, mxc;
  49.  
  50.    if (!wnd) return(0);
  51.    if (!chk_video_state(&mxr, &mxc)) return(0);
  52.    re_order(wnd, NORMAL);
  53.  
  54.    row = wnd->urow + row;
  55.    col = wnd->ucol + col;
  56.  
  57.    if (col >= wnd->lcol) return(0);
  58.    if (col <= wnd->ucol) return(0);
  59.    if (row <= wnd->urow) return(0);
  60.    if (row >= wnd->lrow) return(0);
  61.    if ((col + count - 1) >= wnd->lcol) return(0);
  62.  
  63.    return(chg_attr(row, col, foreground, background, count));
  64. }
  65.  
  66. /**********************************************************/
  67. /*                        Set_Wnd_Attr                    */
  68. /*                                                        */
  69. /* Changes the attribute stored in the WNDPTR structure.  */
  70. /**********************************************************/
  71.  
  72. void set_wnd_attr(WNDPTR *wnd, int fg, int bg) {
  73.  
  74.    if (!wnd) return;
  75.    wnd->attr = (char) ((bg << 4) | fg);
  76. }
  77.